/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package it.polimi.weatherEver.business.boundary;

import it.polimi.weatherEver.business.entity.Invitation;
import java.security.Principal;
import javax.ejb.Stateless;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Ettore
 */
@Stateless
public class InvitationManager {

    @PersistenceContext
    EntityManager em;
    
    @Inject
    Principal principal;
        
    public void save(Invitation invite) {
        em.persist(invite);
    }

    public void remove() {
        em.remove(getCurrentInvitation());
    }

        public Invitation getCurrentInvitation() {
        return em.find(Invitation.class, principal.getName());
    }
    // Add business logic below. (Right-click in editor and choose
    // "Insert Code > Add Business Method")
}
